<?php
	require_once dirname(BASEPATH) . '/application/models/local/data/_init_model.php';
	
	class mod_article_category extends _init_model
	{
		public $ART_CAT_ID;
		public $ART_CAT_NAME;
		
		function __construct(){
			parent::__construct();
		
			$this->tableName = "article_category";		
		}
		function get_category_list(){
			$this->db->order_by('ART_CAT_ID', 'ASC');
			$query = $this->db->get($this->tableName);
			return $query->result_array();
		}
		function get_category_id_by_name($category_name){
			$this->db->select('ART_CAT_ID');
			$this->db->where('ART_CAT_NAME', $category_name);
			$query = $this->db->get($this->tableName);
			
			if ($query->num_rows() > 0)
				return $query->row(0)->ART_CAT_ID;
			else 
				return null;			
		}
		function get_category_for_dropdownlist(){
			$query = $this->db->get($this->tableName);
			
			$return = array();
			if ($query->num_rows() > 0){
				foreach ($query->result() as $row)
					$return[$row->ART_CAT_ID] = $row->ART_CAT_NAME;			
			}
			
			return $return;
		}
		
	}
?>